PEXPECT_VERSION=2.1
PEXPECT_BINARY=pexpect
PEXPECT_SOURCE=$(PEXPECT_BINARY)-$(PEXPECT_VERSION).tar.gz
PEXPECT_SITE=http://ufpr.dl.sourceforge.net/sourceforge/pexpect/
PEXPECT_DIR=$(BUILD_DIR)/$(PEXPECT_BINARY)-$(PEXPECT_VERSION)
PEXPECT_SITE_PKG=$(TARGET_DIR)/usr/lib/python2.4/site-packages/

$(DL_DIR)/$(PEXPECT_SOURCE):
	$(WGET) -P $(DL_DIR) $(PEXPECT_SITE)/$(PEXPECT_SOURCE)

$(PEXPECT_DIR)/.source: $(DL_DIR)/$(PEXPECT_SOURCE)
	tar -C $(BUILD_DIR) -zxf $(DL_DIR)/$(PEXPECT_SOURCE)
	touch $(PEXPECT_DIR)/.source

$(PEXPECT_DIR)/.configured: $(PEXPECT_DIR)/.source
	touch $(PEXPECT_DIR)/.configured

$(PEXPECT_BINARY): python $(PEXPECT_DIR)/.configured
	mkdir -p $(PEXPECT_SITE_PKG)
	cp $(PEXPECT_DIR)/fdpexpect.py $(PEXPECT_SITE_PKG)
	cp $(PEXPECT_DIR)/pexpect.py $(PEXPECT_SITE_PKG)
	cp $(PEXPECT_DIR)/pxssh.py $(PEXPECT_SITE_PKG)	

$(PEXPECT_BINARY)-clean:
	rm -rf $(PEXPECT_SITE_PKG)/fdpexpect.py
	rm -rf $(PEXPECT_SITE_PKG)/pexpect.py
	rm -rf $(PEXPECT_SITE_PKG)/pxssh.py

$(PEXPECT_BINARY)-dirclean:
	rm -rf $(PEXPECT_DIR)

ifeq ($(strip $(BR2_PACKAGE_PEXPECT)),y)
TARGETS+=$(PEXPECT_BINARY)
endif
